package com.demo.redis.pubsub;

import redis.clients.jedis.JedisPubSub;

/**
 * 参考：https://blog.csdn.net/lihao21/article/details/48370687
 * https://blog.csdn.net/u011489043/article/details/78780255
 * https://www.cnblogs.com/foundwant/p/6382083.html
 */
public class Subscriber extends JedisPubSub {

    @Override
    public void onMessage(String channel, String message) {
        System.out.println(String.format("receive redis published message, channel %s, message %s", channel, message));
        super.onMessage(channel, message);
    }

    @Override
    public void onSubscribe(String channel, int subscribedChannels) {
        System.out.println(String.format("subscribe redis channel success, channel %s, subscribedChannels %d", channel, subscribedChannels));
        super.onSubscribe(channel, subscribedChannels);
    }

    @Override
    public void onUnsubscribe(String channel, int subscribedChannels) {
        System.out.println(String.format("unsubscribe redis channel, channel %s, subscribedChannels %d", channel, subscribedChannels));
        super.onUnsubscribe(channel, subscribedChannels);
    }

    @Override
    public void onPong(String pattern) {
        super.onPong(pattern);
    }

    @Override
    public void ping() {
        super.ping();
    }
}
